﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14_LongestCommonPrefix
{
    class Program
    {
        static void Main(string[] args)
        {

        }

        private static string LongestCommonPrefix(string[] strs)
        {
            string result = string.Empty;

            if (strs == null || strs.Length == 0) return "";
            result = strs[0];
            int i = 1;
            while (i < strs.Length)
            {
                while (strs[i].IndexOf(result) != 0)
                    result = result.Substring(0, result.Length - 1);
                i++;
            }

            return result;
        }
    }
}
